#include"ThreadPool.hpp"
#include"Task.hpp"
#include<memory>
#include<ctime>

int main()
{
    EnableConsoleLogStrategy();//指定刷新策略
    srand(time(nullptr));
    
    // std::unique_ptr<ThreadPool<Task>> tp = std::make_unique<ThreadPool<Task>>(5);
    //非静态成员函数必须使用该类对象调用
    // ThreadPool<Task>::GetInstance() ->Start();
    //创建线程池
    // ThreadPool<Task>::GetInstance()-> Start();
    //向线程池中放任务，让线程去执行
    int cnt = 10;
    while(cnt--)
    {
        int a = rand()%10;
        usleep(rand()%73);
        int b = rand()%20;
        Task t(a,b);
        ThreadPool<Task>::GetInstance() ->Enqueue(t);
        sleep(1);
    }

    //关闭线程池
    ThreadPool<Task>::GetInstance() ->Stop();

    //等待线程池中线程
    ThreadPool<Task>::GetInstance() ->Wait();

    return 0;
}